<template>
	<view :style="[{paddingTop:CustomBar+'px'}]">
		<cu-custom bgColor="bg-colorP" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">联盟列表</block>
		</cu-custom>
		<view class="info-item" v-for="(item,index) in chainList" :key="index" :data-url="'/pages/affiliateList?chainId='+item.id"
		 @click="nav">
			<view class="">
				<view class="image" :style="item.style">
					<image :src="item.image+'?x-oss-process=image/resize,m_fill,h_152,w_152'" mode=""></image>
				</view>
				<view class="info">
					<view class="name text-cut">{{item.name}}</view>
					<view class="tags" v-if="item.tags.length > 0">
						<image src="https://xarkbucket.oss-cn-hangzhou.aliyuncs.com/resources/union-label.png" mode=""></image>
						<view class="cont" v-for="(tag,i) in item.tags" :key="i">
							<text>{{tag}}</text>
							<text v-if="index != item.tags.length-1"></text>
						</view>
					</view>
					<view class="nums">
						<image src="https://xarkbucket.oss-cn-hangzhou.aliyuncs.com/resources/union-shop-number.png" mode=""></image>
						<text>{{item.number}}</text>
						<text>家联盟店铺</text>
					</view>
				</view>
			</view>
			<view class="summary">
				盟主有话说：{{item.summary}}
			</view>
		</view>
		<tui-divider width="60%" :gradual="true" v-if="noContentShow">没有更多了~</tui-divider>
	</view>
</template>

<script>
	import tuiDivider from "./component/divider.vue"
	import noContent from "./component/noContent.vue"
	export default {
		components: {
			tuiDivider,
			noContent
		},
		data() {
			return {
				CustomBar: this.CustomBar,
				page: 1,
				lastPage: '',
				chainList: [],
				noContentShow: false
			}
		},
		onLoad() {
			this.getChain()
		},
		onReachBottom() {
			if (this.page > this.lastPage) {
				this.noContentShow = true
				return
			}
			this.getChain()
		},
		methods: {
			// 获取连锁商家
			getChain() {
				var me = this;
				var coordinate = uni.getStorageSync('coordinate')
				this.$request({
					url: '/ChainShop/get_chain_shop_more',
					methods: 'POST',
					data: {
						page: me.page,
						latitude: coordinate.latitude,
						longitude: coordinate.longitude
					},
					success: res => {
						if (res.data.status == 1) {
							var result = res.data.data.data
							me.chainList = me.chainList.concat(result)
							me.lastPage = res.data.data.pageCount
							me.page++
							me.dyeing()
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			// 跳转
			nav(e) {
				var url = e.currentTarget.dataset.url
				if (url) {
					uni.navigateTo({
						url: url
					})
				}
			},
			dyeing() {
				var that = this
				var chainList = this.chainList
				this.$request({
					url: '/ChainShop/get_color_logo',
					success: res => {
						if (res.data.status == 1) {
							chainList.forEach(item => {
								if (!item.style) {
									item.color = item.color ? item.color : '1'
									var bottomColor = res.data.data.color.filter(color => color.id == item.color)
									var style = ''
									style =
										`background-image:linear-gradient(-30deg,${bottomColor[0].start_1},${bottomColor[0].end_1});background-image:-o-linear-gradient(-30deg,${bottomColor[0].start_1},${bottomColor[0].end_1});background-image:-webkit-gradient(linear, left top, right bottom, from(${bottomColor[0].start_1}),to(${bottomColor[0].end_1}));`
									item['style'] = style
								}
							})
							that.chainList = chainList
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},

		}
	}
</script>

<style scoped>
	.info-item {
		width: 100%;
		padding: 30rpx 24rpx 20rpx;
		border-bottom: solid 1rpx #efefef;
		display: flex;
		flex-direction: column;
	}

	.info-item>view:nth-child(1) {
		width: 100%;
		height: 160rpx;
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.info-item>view:nth-child(1) .image {
		width: 160rpx;
		height: 160rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 8rpx;
		margin-right: 20rpx;
	}

	.info-item>view:nth-child(1) .image image {
		width: 152rpx;
		height: 152rpx;
		border-radius: 8rpx;
		display: inline-block;
	}

	.info-item>view:nth-child(1) .info {
		flex: 1;
		height: 160rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		max-width: 500rpx;
	}

	.info-item>view:nth-child(1) .info .name {
		font-size: 30rpx;
		line-height: 36rpx;
		letter-spacing: 1rpx;
		color: #333333;
		font-weight: bold;
	}

	.info-item>view:nth-child(1) .info .tags {
		width: 100%;
		height: 32rpx;
		display: flex;
		align-items: center;
	}

	.info-item>view:nth-child(1) .info .nums image,
	.info-item>view:nth-child(1) .info .tags image {
		width: 32rpx;
		height: 32rpx;
	}

	.info-item>view:nth-child(1) .info .tags .cont {
		flex: 1;
		display: flex;
		align-items: center;
	}

	.info-item>view:nth-child(1) .info .tags .cont text:nth-child(1) {
		padding: 0 10rpx;
		line-height: 32rpx;
		font-size: 24rpx;
		letter-spacing: 1rpx;
		color: #333333;
	}

	.info-item>view:nth-child(1) .info .tags .cont text:nth-child(2) {
		width: 1rpx;
		height: 16rpx;
		background-color: #efefef;
	}

	.info-item>view:nth-child(1) .info .tags .cont text:nth-child(2) {
		width: 1rpx;
		height: 16rpx;
		background-color: #efefef;
	}

	.info-item>view:nth-child(1) .info .nums {
		width: 100%;
		height: 32rpx;
		display: flex;
		align-items: center;
	}

	.info-item>view:nth-child(1) .info .nums text:nth-child(2) {
		padding: 0 10rpx;
		font-size: 30rpx;
		letter-spacing: 1rpx;
		color: #333333;
		line-height: 32rpx;
		font-weight: bold;
	}

	.info-item>view:nth-child(1) .info .nums text:nth-child(3) {
		font-size: 24rpx;
		letter-spacing: 1rpx;
		color: #333333;
		line-height: 32rpx;
	}

	.summary {
		padding: 12rpx 20rpx;
		background-image: linear-gradient(90deg,
			#feebce 0%,
			#fde2ba 100%);
		box-shadow: inset 0rpx 0rpx 19rpx 1rpx rgba(248, 153, 11, 0.2);
		border-radius: 2rpx;
		line-height: 30rpx;
		font-size: 24rpx;
		color: #333333;
	}
</style>

<style>
	page {
		background: #fff;
	}
</style>
